package com.igeek.config;

import com.igeek.domain.Category;
import com.igeek.interceptor.LoginInterceptor;
import com.igeek.interceptor.OtherInterceptor;
import com.igeek.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


@Configuration
class MyWebMvcConfigurer  implements WebMvcConfigurer {


	@Bean
	public OtherInterceptor getOtherIntercepter() {
		return new OtherInterceptor();
	}

	@Bean
	public LoginInterceptor getLoginInterceptor(){return  new LoginInterceptor();}

	@Override
	public void addInterceptors(InterceptorRegistry registry){
		registry.addInterceptor(getOtherIntercepter())
				.addPathPatterns("/**");
		registry.addInterceptor(getLoginInterceptor())
				.addPathPatterns("/**");

	}
}


